package com.hmdp.controller;


import com.hmdp.dto.Result;
import com.hmdp.service.IFollowService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/follow")
public class FollowController {

    @Resource
    private IFollowService followService;

    /**
     *
     * @param followUserId 博主的userId
     * @param isFollow 判断关注还是取关
     * @return
     */
    //关注和取关博主
    @PutMapping("/{id}/{isFollow}")
    public Result follow(@PathVariable("id") Long followUserId, @PathVariable("isFollow") Boolean isFollow){
        return followService.follow(followUserId, isFollow);
    }

    /**
     *
     * @param followUserId 博主的userId
     * @return
     */
    //判断当前用户有无关注该博主
    @GetMapping("/or/not/{id}")
    public Result isFollow(@PathVariable("id") Long followUserId){
        return followService.isFollow(followUserId);
    }

    /**
     * 根据用户id查询与当前用户共同关注的用户基本信息
     * @param userId 用户id
     * @return
     */
    @GetMapping("/common/{id}")
    public Result followCommons(@PathVariable("id") Long userId){
        return followService.followCommons(userId);
    }

    /**
     * 返回当前用户的粉丝数量
     * @return
     */
    @GetMapping("/count")
    public Result countOfFollows(){
        return followService.countOfFollows();
    }

    /**
     * 返回当前用户的粉丝信息
     * @return
     */
    @GetMapping("/info")
    public Result infoOfFollows(){
        return followService.infoOfFollows();
    }

}
